#include <cstdio>
#include <queue>

using namespace std;

struct Node {
    int a, b, c;
    int t;
};

queue<Node> node_queue;

bool mark[101][101][101];

void cup_dump(int &volume_1, int cup_1, int &volume_2, int cup_2);

int BFS(int s, int n, int m);

int main(int argc, char const *argv[]) {
    int s, n, m;
    while (scanf("%d%d%d", &s, &n, &m) != EOF) {
        if (s == 0)
            break;
        if (s % 2 == 1) {
            puts("NO");
            continue;
        }
        for (int i = 0; i <= s; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < m; ++k) {
                    mark[i][j][k] = false;
                }
            }
        }
        Node start_node;
        start_node.a = s;
        start_node.b = 0;
        start_node.c = 0;
        start_node.t = 0;
        while (!node_queue.empty())
            node_queue.pop();
        node_queue.push(start_node);
        mark[s][0][0] = true;
        int result = BFS(s, n, m);
        if (result == -1)
            puts("NO");
        else
            printf("%d\n", result);
    }
    return 0;
}

void cup_dump(int &volume_1, int cup_1, int &volume_2, int cup_2) {
    if (cup_2 - volume_2 >= volume_1) { //cup_1 all to cup_2
        volume_2 += volume_1;
        volume_1 = 0;
    } else {
        volume_1 -= cup_2 - volume_2;
        volume_2 = cup_2;
    }
}

int BFS(int s, int n, int m) {
    while (!node_queue.empty()) {
        Node current_node = node_queue.front();
        node_queue.pop();
        int a, b, c;
        a = current_node.a;
        b = current_node.b;
        c = current_node.c;
        cup_dump(a, s, b, n); //s to n
        if (!mark[a][b][c]) {
            mark[a][b][c] = true;
            Node temp_node;
            temp_node.a = a;
            temp_node.b = b;
            temp_node.c = c;
            temp_node.t = current_node.t + 1;
            if (a == s / 2 && b == s / 2)
                return temp_node.t;
            if (c == s / 2 && b == s / 2)
                return temp_node.t;
            if (a == s / 2 && c == s / 2)
                return temp_node.t;
            node_queue.push(temp_node);
        }
        a = current_node.a;
        b = current_node.b;
        c = current_node.c;
        cup_dump(b, n, a, s); //n to s
        if (!mark[a][b][c]) {
            mark[a][b][c] = true;
            Node temp_node;
            temp_node.a = a;
            temp_node.b = b;
            temp_node.c = c;
            temp_node.t = current_node.t + 1;
            if (a == s / 2 && b == s / 2)
                return temp_node.t;
            if (c == s / 2 && b == s / 2)
                return temp_node.t;
            if (a == s / 2 && c == s / 2)
                return temp_node.t;
            node_queue.push(temp_node);
        }
        a = current_node.a;
        b = current_node.b;
        c = current_node.c;
        cup_dump(a, s, c, m); //s to m
        if (!mark[a][b][c]) {
            mark[a][b][c] = true;
            Node temp_node;
            temp_node.a = a;
            temp_node.b = b;
            temp_node.c = c;
            temp_node.t = current_node.t + 1;
            if (a == s / 2 && b == s / 2)
                return temp_node.t;
            if (c == s / 2 && b == s / 2)
                return temp_node.t;
            if (a == s / 2 && c == s / 2)
                return temp_node.t;
            node_queue.push(temp_node);
        }
        a = current_node.a;
        b = current_node.b;
        c = current_node.c;
        cup_dump(c, m, a, s); //m to s
        if (!mark[a][b][c]) {
            mark[a][b][c] = true;
            Node temp_node;
            temp_node.a = a;
            temp_node.b = b;
            temp_node.c = c;
            temp_node.t = current_node.t + 1;
            if (a == s / 2 && b == s / 2)
                return temp_node.t;
            if (c == s / 2 && b == s / 2)
                return temp_node.t;
            if (a == s / 2 && c == s / 2)
                return temp_node.t;
            node_queue.push(temp_node);
        }
        a = current_node.a;
        b = current_node.b;
        c = current_node.c;
        cup_dump(b, n, c, m); //n to m
        if (!mark[a][b][c]) {
            mark[a][b][c] = true;
            Node temp_node;
            temp_node.a = a;
            temp_node.b = b;
            temp_node.c = c;
            temp_node.t = current_node.t + 1;
            if (a == s / 2 && b == s / 2)
                return temp_node.t;
            if (c == s / 2 && b == s / 2)
                return temp_node.t;
            if (a == s / 2 && c == s / 2)
                return temp_node.t;
            node_queue.push(temp_node);
        }
        a = current_node.a;
        b = current_node.b;
        c = current_node.c;
        cup_dump(c, m, b, n); //m to n
        if (!mark[a][b][c]) {
            mark[a][b][c] = true;
            Node temp_node;
            temp_node.a = a;
            temp_node.b = b;
            temp_node.c = c;
            temp_node.t = current_node.t + 1;
            if (a == s / 2 && b == s / 2)
                return temp_node.t;
            if (c == s / 2 && b == s / 2)
                return temp_node.t;
            if (a == s / 2 && c == s / 2)
                return temp_node.t;
            node_queue.push(temp_node);
        }
    }
    return -1;
}